/* 762. 二进制表示中质数个计算置位 */
/**
 * @param {number} left
 * @param {number} right
 * @return {number}
 */
const bitCount = (x) => {
    return x.toString(2).split("0").join("").length
}
/* 暴力 */
var countPrimeSetBits = function (left, right) {
    const isPrimeNumber = (number) => {
        if (number < 2) return false
        for (let j = 2; j * j <= number; j++) {
            if (number % j === 0) {
                return false
            }
        }
        return true
    }
    let result = 0
    for (let i = left; i <= right; i++) {
        if (isPrimeNumber(bitCount(i))) result++
    }
    return result
};
/* 优化 */
var countPrimeSetBits = function (left, right) {
    let result = 0
    for (let x = left; x <= right; x++) {
        if (1 << bitCount(x) & 665772) result++
    }
    return result
}

var countPrimeSetBits = function (left, right) {
    const isSamePrime = (x) => {
        const primeNum = [2, 3, 5, 7, 11, 13, 17, 19]
        return primeNum.includes(x)
    }
    let result = 0
    for (let x = left; x <= right; x++) {
        if (isSamePrime(bitCount(x))) result++
    }

    return result
}
const result = countPrimeSetBits(10, 15)
console.log('result :>>', result);


